<script type="text/javascript">
$(function(){

<?php if(isset($events)&&$events=='create'){?>
    $('#btnEditor').hide();
    $('#btnPreview').show();
    $('<?php echo '.editor'.$wid?>').show();
    //$('.editor').html($('#content').html());
    $('<?php echo '.preview'.$wid?>').html();

<?php }else {?>

    $('#btnEditor').show();
    $('#btnPreview').hide();
    $('<?php echo '.editor'.$wid?>').hide();
    $('<?php echo '.preview'.$wid?>').html($('<?php echo '#content'.$wid?>').html());

<?php }?>


   $('<?php echo '#content'.$wid?>').tinymce({
        plugins : '-example',
        language : 'zh-cn',
        theme : "advanced",
        mode : "textareas",
        theme_advanced_buttons1 : "newdocument,|,bold,italic,underline,strikethrough,|,justifyleft,justifycenter,justifyright,justifyfull,|,fontselect,fontsizeselect",
        theme_advanced_buttons2 : "undo,redo,|,link,unlink,|,forecolor,backcolor",
        theme_advanced_buttons3 : "",
        //theme_advanced_buttons3_add : "preview",
        //plugin_preview_width : "500",
        //plugin_preview_height : "600"
        theme_advanced_toolbar_location : "top",
        theme_advanced_toolbar_align : "left",
        theme_advanced_statusbar_location : "bottom",
        //theme_advanced_resizing : true

});

$('<?php echo '.btnpreview2'.$wid?>').click(function(){
    $('#btnEditor').show();
    $('#btnPreview').hide();
    $('<?php echo '.editor'.$wid?>').hide();
    $('<?php echo '.preview'.$wid?>').html($("<?php echo '#content'.$wid?>").html());
});

// $('.preview').doubleClick(function(){
  // //$('.textcore').load("/mr8/index.php?r=jwidget/widget/loadTextPreview",{'content':$('#content').html()});
//   
    // $('#btnEditor').show();
    // $('#btnPreview').hide();
    // $('.editor').hide();
    // $('.preview').html($('#content').html());
// });

});

</script>
<style>
#content{
clear:both;
}
</style>
 <div class='editor <?php echo 'editor'.$wid?>'>
  <textarea id='<?php echo 'content'.$wid?>'name="content" cols="50" rows="15"></textarea>
   <input type='button' class='<?php echo 'btnpreview2'.$wid?>'/> 
 </div>
 <div class='preview <?php echo 'preview'.$wid?>'>
 </div>
